package com.qf.homeworkssm.exhandler;


import com.qf.homeworkssm.vo.ResultVo;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice  //全局异常处理类，返回的Json数据
public class GlobalHandler {

    @ExceptionHandler(Exception.class)  //需要处理的异常类型是什么
    public ResultVo handlerEx(Exception e){


        return ResultVo.fail(e.getMessage());
    }


    @ExceptionHandler(ParamNullExeception.class)
    public ResultVo handlerParamNullEx(ParamNullExeception exeception){
        Integer code = exeception.getCode();
        String msg = exeception.getMsg();
        return ResultVo.fail(msg);
    }

}
